package com.zengdw.logRecord.config;

import com.zengdw.logRecord.aop.LogRecordAspect;
import com.zengdw.logRecord.resolve.IParseFunction;
import com.zengdw.logRecord.resolve.ParseFunctionFactory;
import com.zengdw.logRecord.service.ILogRecordService;
import com.zengdw.logRecord.service.IOperatorService;
import com.zengdw.logRecord.service.impl.LogRecordServiceImpl;
import com.zengdw.logRecord.service.impl.OperatorServiceImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
 * @author zengd
 * @date 2021/9/18 10:34
 */
@Configuration
public class LogRecordProxyAutoConfiguration {
    @Bean
    public ParseFunctionFactory parseFunctionFactory(List<IParseFunction> parseFunctions) {
        return new ParseFunctionFactory(parseFunctions);
    }

    @Bean
    public LogRecordAspect logRecordAspect(IOperatorService operatorService, ParseFunctionFactory parseFunctionFactory,
                                           ILogRecordService logRecordService) {
        return new LogRecordAspect(operatorService, parseFunctionFactory, logRecordService);
    }

    @Bean
    public IOperatorService operatorService() {
        return new OperatorServiceImpl();
    }

    @Bean
    public ILogRecordService logRecordService() {
        return new LogRecordServiceImpl();
    }
}
